package main;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Collections;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JLabel;

public class Group {

	private ArrayList<String> list = new ArrayList<String>();
	private String groupName;

	public Group(int num) {
		groupName = String.valueOf(num);
	}

	public Group(String str) {
		groupName = str;
	}

	public void addToGroup(String name) {
		list.add(name);
		Collections.sort(list);
	}

	public Box getGroup() {
		Box myBox = Box.createVerticalBox();
		myBox.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.black), "Group: " + groupName));
		for (String str : list)
			myBox.add(new JLabel(str));
		return myBox;
	}

	public String toString() {
		String str = "";
		for (String s : list)
			str += (s + ",");
		return str.substring(0, str.length() - 1);
	}
}